Add TryPinInitWrapper trait.#37
Conversation
BennoLossin
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I have a couple notes. Overall using a cargo feature is the correct design. Do note that I port all commits back into the kernel (but only for the files that are there), so please follow the commit message conventions from there.
I do think that we should also think about which other types could make use of implementing the trait that you introduce here.
Formatting done by the `Even Better TOML` vs-code extension. Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com>
In core we could additionally implement it for In std we could implement it for the In the kernel for |
196dd27 to
ef8d073
Compare
|
Split this into three commits:
|
I don't think it's worth it for
Why? We already have the |
|
Ah and one more thing, could you add the information about the feature gate to the readme and include an entry in the changelog? Thanks! |
|
Should I do that as a separate commit? |
I'll add
I guess its useful, I was mostly thinking that |
ef8d073 to
3155517
Compare
BennoLossin
left a comment
There was a problem hiding this comment.
a couple more minor changes, thanks for keeping up so quickly!
9440f53 to
391caae
Compare
This trait allows crating `PinInitializers` for wrapper or new-type structs with the inner value structurally pinned, when given the initializer for the inner value. This commit implements this trait for `UnsafeCell` and `MaybeUninit`. Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com>
Add the `unsafe-pinned` feature which gates the `Wrapper` implementation of the `core::pin::UnsafePinned` struct. For now this is just a cargo feature, but once `core::pin::UnsafePinned` is stable a config flag can be added to allow the usage of this implementation in the linux kernel. Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com>
391caae to
f670aa7
Compare
f670aa7 to
f7f4fc8
Compare
Add Changelog entry for the `Wrapper` trait and document the `unsafe-pinned` feature in the Readme. Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com>
The previous link anchor was broken in rust 1.77, because the documentation was refactored in upstream rust. Change the link to refer to the new section in the rust documentation. Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com>
f7f4fc8 to
a146142
Compare
BennoLossin
left a comment
There was a problem hiding this comment.
All looks good now, thanks a lot!
Implement it for
UnsafeCellandUnsafePinned(unsafe-pinned feature is enabled.There are probably a large amount of other types where a implementation might be useful,
but for now only implement these types. Others can be implemented in follow-ups.
I'm not sure how to handle enabling the
UnsafePinned, for now I've just implemented it as a cargo feature.